<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml">
<head>

    <meta charset="UTF-8">
    <title>recordInfo</title>
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script src="/js/vue.global.js"></script>
    <script src="/js/axios.min.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="/css/bootstrap.css">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="/css/bootstrap-theme.css"
    >

    <!--    <link rel="stylesheet" href="/css/bootstrapValidator.css"/>-->

    <!--    <script type="text/javascript" src="/js/bootstrapValidator.js"></script>-->
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="/js/bootstrap.min.js"
            crossorigin="anonymous"></script>

    <script src="/js/distpicker.js"></script>

</head>
<body>

<form action="/user/logout" method="post">
    <input class="submit" type="submit" value="退出登录">
</form>


<div class="container">
    <div class="row">
        <!-- form: -->
        <section>
            <div class="col-lg-8 col-lg-offset-2">
                <div class="page-header">
                    <h2>疫情防控，人人有责</h2>
                    <h3 style="color: red" id="recorded_alert" hidden>您今日已打卡，请勿重复打卡</h3>
                </div>

                <form id="myForm" method="post" class="form-horizontal" action="/user/submit">

                    <div class="form-group">
                        <label class="col-lg-3 control-label">学生id
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-4">
                            <input v-model="stuId" type="text" id="stu_id" readonly=" readonly" class="form-control" name="stuId"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-3 control-label">学生姓名
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <input v-model="name" id="name" readonly=" readonly" name="name" type="text" class="form-control formVal">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-3 control-label">手机号码
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <input v-model="phone" id="phone" name="phone" readonly=" readonly" type="text"
                                   class="form-control formVal">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-3 control-label">日期
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <input v-model="date" id="date" readonly=" readonly" name="date" type="date" class="form-control formVal">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-3 control-label">当前健康状态
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <div class="form-check"><label class="form-check-label"><input v-model="health" id="health" name="health"
                                                                                           type="radio"
                                                                                           class="form-check-input checkMargin"
                                                                                           value="健康">健康</label>
                            </div>
                            <div class="form-check"><label class="form-check-label"><input v-model="health" id="danger" type="radio"
                                                                                           class="form-check-input checkMargin"
                                                                                           name="health"
                                                                                           value="异常（出现发热、咳嗽，体温高于37.3℃）">异常（出现发热、咳嗽，体温高于37.3℃）</label>
                            </div>
                            <div class="form-check"><label class="form-check-label"><input v-model="health" id="other" type="radio"
                                                                                           class="form-check-input checkMargin"
                                                                                           name="health" value="有其他疾病">有其他疾病</label>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-3 control-label">是否到达过疫情重点地区
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <div class="form-check"><label class="form-check-label"><input v-model="dangerAreReach" id="dangerAreReach"
                                                                                           type="radio"
                                                                                           class="form-check-input checkMargin"
                                                                                           name="dangerAreaReach"
                                                                                           value="是">是</label></div>
                            <div class="form-check"><label class="form-check-label"><input v-model="dangerAreReach" type="radio"
                                                                                           id="dangerAreNotReach"
                                                                                           class="form-check-input checkMargin"
                                                                                           name="dangerAreaReach"
                                                                                           value="否">否</label></div>

                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-3 control-label">是否接触过疫情重点人员
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <div class="form-check"><label class="form-check-label"><input v-model="dangerPeopleAttach" type="radio"
                                                                                           id="dangerPeopleAttach"
                                                                                           class="form-check-input checkMargin"
                                                                                           name="dangerPeopleContact"
                                                                                           value="是">是</label></div>
                            <div class="form-check"><label class="form-check-label"><input v-model="dangerPeopleAttach" type="radio"
                                                                                           id="dangerPeopleNotAttach"
                                                                                           class="form-check-input checkMargin"
                                                                                           name="dangerPeopleContact"
                                                                                           value="否">否</label></div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-3 control-label">您是否为疫情防控的重点人员
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <div class="form-check"><label class="form-check-label"><input v-model="dangerMark" type="radio" id="dangerMark"
                                                                                           class="form-check-input checkMargin"
                                                                                           name="dangerMark"
                                                                                           value="是">是</label></div>
                            <div class="form-check"><label class="form-check-label"><input v-model="dangerMark" type="radio"
                                                                                           id="dangerNotMark"
                                                                                           class="form-check-input checkMargin"
                                                                                           name="dangerMark"
                                                                                           value="否">否</label></div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-3 control-label">紧急联系人姓名
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <input v-model="emergencyContactName" name="emergencyContactName" id="emergencyContactName" type="text" class="form-control formVal">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-3 control-label">紧急联系人电话
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <input v-model="emergencyContactPhone" name="emergencyContactPhone" id="emergencyContactPhone" type="text" class="form-control formVal">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-3 control-label">体温
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <input v-model="temperature" name="temperature" id="temperature" type="text" class="form-control formVal">
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-lg-3 control-label">您现在所在区域
                            <div class="required" style="display: inline;color: red">*</div>
                        </label>
                        <div class="col-lg-5">
                            <input  id="locationText" hidden type="text" readonly>
                            <div data-toggle="distpicker" id="location">

                                <select v-model="locationProvince" id="locationProvinceId" name="locationProvince" data-province="选择省"
                                        style="display: inline;width: 100px"></select>
                                <select v-model="locationCity" id="locationCityId" name="locationCity" data-city="选择市"
                                        style="display: inline;width: 100px"></select>
                                <select v-model="locationVillage" id="locationVillageId" name="locationVillage" data-district="选择区"
                                        style="display: inline;width: 100px"></select>
                            </div>
                            <div class="errorMain"></div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-lg-9 col-lg-offset-3">
                            <button id="submit_button" type="submit" class="btn btn-primary" value="Sign up">提交</button>
                        </div>
                    </div>

                </form>
            </div>
        </section>
        <!-- :form -->
    </div>
</div>


<script>


    axios.get('/user/getBaseInfo')
        .then(function (response) {
            const data = response.data.data
            console.log(response)

            document.getElementById("stu_id").setAttribute("value", data.id)
            document.getElementById("name").setAttribute("value", data.name)
            document.getElementById("phone").setAttribute("value", data.phone)
            // document.getElementById("date").setAttribute("value",new Date().toDateString())
            document.getElementById("date").valueAsDate = new Date();
            console.log(response);
        })
        .catch(function (error) {
            console.log(error);
        });


    axios.get('/user/getNewestRecord')
        .then(function (response) {
            const data = response.data.data

            if (data!=null){

                if (data.health=="健康"){
                    document.getElementById("health").setAttribute("checked", true)
                }
                if (data.health=="异常（出现发热、咳嗽，体温高于37.3℃）"){
                    document.getElementById("danger").setAttribute("checked", true)
                }
                if (data.health=="有其他疾病"){
                    document.getElementById("other").setAttribute("checked", true)
                }
                if (data.dangerAreaReach=="是"){
                    document.getElementById("dangerAreReach").setAttribute("checked", true)
                }
                if (data.dangerAreaReach=="否"){
                    document.getElementById("dangerAreNotReach").setAttribute("checked", true)
                }
                if (data.dangerPeopleContact=="是"){
                    document.getElementById("dangerPeopleAttach").setAttribute("checked", true)
                }
                if (data.dangerPeopleContact=="否"){
                    document.getElementById("dangerPeopleNotAttach").setAttribute("checked", true)
                }
                if (data.dangerMark=="是"){
                    document.getElementById("dangerMark").setAttribute("checked", true)
                }
                if (data.dangerMark=="否"){
                    document.getElementById("dangerNotMark").setAttribute("checked", true)
                }

                document.getElementById("emergencyContactName").setAttribute("value", data.emergencyContactName)
                document.getElementById("emergencyContactPhone").setAttribute("value", data.emergencyContactPhone)
                document.getElementById("temperature").setAttribute("value", data.temperature)



            }
            var date=new Date(data.date)
            var ddate = new Date()
            if(date.getFullYear()== ddate.getFullYear() && date.getMonth()== ddate.getMonth() &&
                date.getDate()== ddate.getDate())  {
                document.getElementById("recorded_alert").hidden=false
                document.getElementById("submit_button").setAttribute("style","display:none")
                document.getElementById("location").hidden=true
                document.getElementById("locationText").hidden=false
                document.getElementById("locationText").setAttribute("value", data.locationProvince+"-"+data.locationCity+"-"+data.locationVillage)
            }



            // document.getElementById().setAttribute()
            //
            // document.getElementById("stu_id").setAttribute("value",data.id)
            // document.getElementById("name").setAttribute("value",data.name)
            // document.getElementById("phone").setAttribute("value",data.phone)
            // // document.getElementById("date").setAttribute("value",new Date().toDateString())
            // document.getElementById("date").valueAsDate = new Date();
            // console.log(response);
        })
        .catch(function (error) {
            console.log(error);
        });

</script>
<style>
    .main {
        /*text-align: center; !*让div内部文字居中*!*/
        background-color: #fff;
        border-radius: 20px;
        width: 300px;
        height: 350px;
        margin: auto;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
</style>
</body>


</html>